﻿using System.Linq;
using System.Text;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace NazTek.Documenter.Ssis.Control.Tasks.PipeSubComponent
{
    internal sealed class UnionAll : Base
    {
        internal UnionAll(SsisPipe parent, IDTSComponentMetaData100 subComponent)
            : base(subComponent, parent)
        {
        }

        protected override Operation GetOperation(SsisPipe parent)
        {
            var statement = new StringBuilder("Data Sources:<br>");
            var inputs = Metadata.InputCollection.Cast<IDTSInput100>().ToArray().Select(inp => inp.Name);
            foreach (var match in parent.Paths.Where(p => inputs.Contains(p.EndPoint.Name)))
                statement.AppendFormat("\t{0}<br>", match.Name);
            return new Operation
            {
                ConnectionName = "Not Applicable",
                Statement = statement.ToString()
            };
        }
    }
}